capture log close
clear all
set linesize 120
macro drop _all
clear all
set more off

*/ SET DIRECTORY */

*/ START LOG FILE */

log using WhyLeadersFightDyadicReplication.log, replace

*/ LOAD DATASET */

use WhyLeadersFightDyadicReplication.dta, clear

*/ Table 3.1 */
*/ Uses leader peace year splines, not country peace year splines, as per footnote 57 on page 120 */

logit cwinit milnoncombat combat rebel warwin warloss rebelwin rebelloss leveledu age teacher journalism law medicine religion activist careerpolitician creative business aristocratlandowner police militarycareer scienceeng bluecollar gender totalspouses married marriedinpower divorced childtotal parstability illegit royalty orphanbinary officetenure1000 leaderpeaceyrs1 leaderpeaceyrs2 leaderpeaceyrs3 if random==1, robust cluster(leaderid)
estimates store m1

predict p
label var p "Predicted Leader Risk Score"

drop if random==1

logit cwinit p dem1 dem2 jointdem sideabof defpact contigld syscon satisdy numGPs cwpceyrs1 cwpceyrs2 cwpceyrs3 if random==0, robust cluster(dyadid)
estimates store m2

margins, atmeans vsquish
margins, atmeans at((p10)syscon) at((p90) syscon) at(contigld=0) at(contigld=1) at(dem1=1 dem2=1 jointdem=1) at((p10)satisdy) at((p90)satisdy) at((p10)numGPs) at((p90)numGPs) at(defpact=0) at(defpact=1) at((p10)sideabof) at((p90)sideabof) at((p10)p) at((p90)p) vsquish

*/ Use these to generate Table 3.1 */
*/ Note that these totals are *very* slighty off Table 3.1 due to a last minute coding update not reflected in the table in the book */

*/ Figure 3.14 */

margins, atmeans at((min)p) at((p10)p) at((p20)p) at((p30)p) at((p40)p) at((p50)p) at((p60)p) at((p70)p) at((p80)p) at((p90)p)

*/ Appendix */

*/ Regression Table for Table 3.1 */

esttab m1 m2 using AppendixTableA_10.rtf, replace onecell se pr2 t(3) b(a3) scalars(ll) legend label collabels(none) varlabels(_cons Constant) star(* 0.10 ** 0.05 *** 0.01) mtitles("Leader Risk Model On First Half Of Data" "Combined Model On Second Half Of Data")

*/ Appendix Table with A). Dem High/Dem Low and B). Polity interaction instead of Democracy Dummy */

logit cwinit p demhigh demlow sideabof defpact contigld syscon satisdy numGPs cwpceyrs1 cwpceyrs2 cwpceyrs3 if random==0, robust cluster(dyadid)
estimates store m3

esttab m3 using AppendixTableA_11.rtf, replace onecell se pr2 t(3) b(a3) scalars(ll) legend label collabels(none) varlabels(_cons Constant) star(* 0.10 ** 0.05 *** 0.01) mtitles("Alternative Regime Type Measure: Dem Low")

estimates clear
clear

*/ Results described on pp. 121-122 in Why Leaders Fight concerning alternative DVs for Table 3.1 */

use WhyLeadersFightDyadicReplication.dta, clear

*/ Re-estimate Table 3.1 w/ force DV */

logit force2dv milnoncombat combat rebel warwin warloss rebelwin rebelloss leveledu age teacher journalism law medicine religion activist careerpolitician creative business aristocratlandowner police militarycareer scienceeng bluecollar gender totalspouses married marriedinpower divorced childtotal parstability illegit royalty orphanbinary officetenure1000 leaderpeaceyrs1 leaderpeaceyrs2 leaderpeaceyrs3 if random==1, robust cluster(leaderid)
predict p
label var p "Predicted Leader Risk Score"
order p random

drop if random==1

logit force2dv p dem1 dem2 jointdem sideabof defpact contigld syscon satisdy numGPs cwpceyrs1 cwpceyrs2 cwpceyrs3 if random==0, robust cluster(dyadid)
estimates store m1

clear
use WhyLeadersFightDyadicReplication.dta, clear

*/ Switch here to peace years based on the Carter & Signorino method because the model does not converge otherwise */
logit fatalmid milnoncombat combat rebel warwin warloss rebelwin rebelloss leveledu age teacher journalism law medicine religion activist careerpolitician creative business aristocratlandowner police militarycareer scienceeng bluecollar gender totalspouses married marriedinpower divorced childtotal parstability illegit royalty orphanbinary officetenure1000 leadernoinit leadernoinit2 leadernoinit3 if random==1, robust cluster(leaderid)
predict p
label var p "Predicted Leader Risk Score"
order p random

drop if random==1

logit fatalmid p dem1 dem2 jointdem sideabof defpact contigld syscon satisdy numGPs cwpceyrs1 cwpceyrs2 cwpceyrs3 if random==0, robust cluster(dyadid)
estimates store m2

esttab m1 m2 using AppendixTableA_12.rtf, replace onecell se pr2 t(3) b(a3) scalars(ll) legend label collabels(none) varlabels(_cons Constant) star(* 0.10 ** 0.05 *** 0.01) mtitles("Both Sides Use Force DV" "Fatal Dispute DV")

estimates clear
clear

*/ Results described on pp. 122-123 in Why Leaders Fight */

use WhyLeadersFightDyadicReplication.dta, clear

*/ Re-estimate Table 3.1 */

logit cwinit milnoncombat combat rebel warwin warloss rebelwin rebelloss leveledu age teacher journalism law medicine religion activist careerpolitician creative business aristocratlandowner police militarycareer scienceeng bluecollar gender totalspouses married marriedinpower divorced childtotal parstability illegit royalty orphanbinary officetenure1000 leaderpeaceyrs1 leaderpeaceyrs2 leaderpeaceyrs3 if random==1, robust cluster(leaderid)
predict p
label var p "Predicted Leader Risk Score"
drop if random==1
logit cwinit p dem1 dem2 jointdem sideabof defpact contigld syscon satisdy numGPs cwpceyrs1 cwpceyrs2 cwpceyrs3 if random==0, robust cluster(dyadid)

*/ pp. 122-123: generate predicted MID initiation scores for 99th percentile and 100th percentile of leader risk and compare to baseline */

margins, atmeans vsquish
margins, atmeans at((p99)p) at((max)p)

*/ pp. 122-123: generate leader risk score for when both side A and side B have significant material power and vary leader risk */

logit cwinit p dem1 dem2 jointdem cap_1 cap_2 defpact contigld syscon satisdy numGPs cwpceyrs1 cwpceyrs2 cwpceyrs3 if random==0, robust cluster(dyadid)
margins, at((mean) _all (max) cap_1 (max) cap_2 (mean) p) at((mean) _all (max) cap_1 (max) cap_2 (p98) p) at((mean) _all (max) cap_1 (max) cap_2 (max) p)

clear

*/ Figure 3.15 */
*/ Load full dataset, generate variable to distinguish which side the balance of forces favors, and show how that varies across monadic leader risk score */

use WhyLeadersFightDyadicReplication.dta, clear

sum sideabof
gen test=.
replace test=0 if sideabof<.5001306
replace test=1 if sideabof>.5001306 & sideabof<1

twoway (scatter monadicleaderrisk sideabof if cwinit==1 & test==0, sort mcolor(gs10)) (scatter monadicleaderrisk sideabof if cwinit==1 & test==1, sort mcolor(black)), ytitle(Leader Risk Score (0 = Low, 1 = High)) ytitle(, margin(medsmall)) ylabel(, nogrid) xtitle(Balance of Forces (0 = 100% Side B, 1 = 100% Side A)) xtitle(, margin(medsmall)) legend(order(1 "Balance of Forces = 100% Side B to Equal" 2 "Balance of Forces = Equal to 100% Side A") r(2) region(lcolor(white))) graphregion(fcolor(white) lcolor(white) ifcolor(white) ilcolor(white)) plotregion(fcolor(white) lcolor(white) ifcolor(white) ilcolor(white))

graph save Graph Figure3_15.gph, replace

estimates clear
clear

*/ Figure 3.17 */
*/ Summarize p, substitute min and max, and generate predicted values */

use WhyLeadersFightDyadicReplication.dta, clear

logit cwinit milnoncombat combat rebel warwin warloss rebelwin rebelloss leveledu age teacher journalism law medicine religion activist careerpolitician creative business aristocratlandowner police militarycareer scienceeng bluecollar gender totalspouses married marriedinpower divorced childtotal parstability illegit royalty orphanbinary officetenure1000 leaderpeaceyrs1 leaderpeaceyrs2 leaderpeaceyrs3 if random==1, robust cluster(leaderid)

predict p
label var p "Predicted Leader Risk Score"

drop if random==1

summarize p if random==0

gen ppolity=p*polity21
label variable ppolity "Polity * Predicted Leader Risk Score"

estsimp logit cwinit p ppolity polity21 sideabof defpact contigld syscon cwpceyrs1 cwpceyrs2 cwpceyrs3 if random==0, robust cluster(dyadid)

setx mean
simqi, pr

setx p max polity21 1 ppolity 1*.0289596
simqi, pr genpr(max1)
setx p max polity21 2 ppolity 2*.0289596
simqi, pr genpr(max2)
setx p max polity21 3 ppolity 3*.0289596
simqi, pr genpr(max3)
setx p max polity21 4 ppolity 4*.0289596
simqi, pr genpr(max4)
setx p max polity21 5 ppolity 5*.0289596
simqi, pr genpr(max5)
setx p max polity21 6 ppolity 6*.0289596
simqi, pr genpr(max6)
setx p max polity21 7 ppolity 7*.0289596
simqi, pr genpr(max7)
setx p max polity21 8 ppolity 8*.0289596
simqi, pr genpr(max8)
setx p max polity21 9 ppolity 9*.0289596
simqi, pr genpr(max9)
setx p max polity21 10 ppolity 10*.0289596
simqi, pr genpr(max10)
setx p max polity21 11 ppolity 11*.0289596
simqi, pr genpr(max11)
setx p max polity21 12 ppolity 12*.0289596
simqi, pr genpr(max12)
setx p max polity21 13 ppolity 13*.0289596
simqi, pr genpr(max13)
setx p max polity21 14 ppolity 14*.0289596
simqi, pr genpr(max14)
setx p max polity21 15 ppolity 15*.0289596
simqi, pr genpr(max15)
setx p max polity21 16 ppolity 16*.0289596
simqi, pr genpr(max16)
setx p max polity21 17 ppolity 17*.0289596
simqi, pr genpr(max17)
setx p max polity21 18 ppolity 18*.0289596
simqi, pr genpr(max18)
setx p max polity21 19 ppolity 19*.0289596
simqi, pr genpr(max19)
setx p max polity21 20 ppolity 20*.0289596
simqi, pr genpr(max20)
setx p max polity21 21 ppolity 21*.0289596
simqi, pr genpr(max21)

setx mean

setx p min polity21 1 ppolity 1*2.39e-18
simqi, pr genpr(min1)
setx p min polity21 2 ppolity 2*2.39e-18
simqi, pr genpr(min2)
setx p min polity21 3 ppolity 3*2.39e-18
simqi, pr genpr(min3)
setx p min polity21 4 ppolity 4*2.39e-18
simqi, pr genpr(min4)
setx p min polity21 5 ppolity 5*2.39e-18
simqi, pr genpr(min5)
setx p min polity21 6 ppolity 6*2.39e-18
simqi, pr genpr(min6)
setx p min polity21 7 ppolity 7*2.39e-18
simqi, pr genpr(min7)
setx p min polity21 8 ppolity 8*2.39e-18
simqi, pr genpr(min8)
setx p min polity21 9 ppolity 9*2.39e-18
simqi, pr genpr(min9)
setx p min polity21 10 ppolity 10*2.39e-18
simqi, pr genpr(min10)
setx p min polity21 11 ppolity 11*2.39e-18
simqi, pr genpr(min11)
setx p min polity21 12 ppolity 12*2.39e-18
simqi, pr genpr(min12)
setx p min polity21 13 ppolity 13*2.39e-18
simqi, pr genpr(min13)
setx p min polity21 14 ppolity 14*2.39e-18
simqi, pr genpr(min14)
setx p min polity21 15 ppolity 15*2.39e-18
simqi, pr genpr(min15)
setx p min polity21 16 ppolity 16*2.39e-18
simqi, pr genpr(min16)
setx p min polity21 17 ppolity 17*2.39e-18
simqi, pr genpr(min17)
setx p min polity21 18 ppolity 18*2.39e-18
simqi, pr genpr(min18)
setx p min polity21 19 ppolity 19*2.39e-18
simqi, pr genpr(min19)
setx p min polity21 20 ppolity 20*2.39e-18
simqi, pr genpr(min20)
setx p min polity21 21 ppolity 21*2.39e-18
simqi, pr genpr(min21)

*/ Use this data to generate Figure 3.17 */
*/ Given use of clarify, exact totals will vary each time */

*/ Footnote 55 on page 119: Alternate Randomization: Replication of Regression Results For Table 3.1 */
*/ Randomizing on the leader year, as we do in Why Leaders Fight, is theoretically preferable for reasons described in "Why Leaders Fight Replication Information" */
*/ However, this demonstrates robustness with alternative randomization */
*/ While the magnitudes change in some ways, the overall results are extremely consistent */

estimates clear
clear
use WhyLeadersFightDyadicReplication.dta, clear

*/ Randomizing on the leader, not the leader year*/
egen randleadid=group(leaderid)
gen leadodd = mod(randleadid,2)
label variable leadodd "Randomly assigned leaders to 1 or 0"

logit cwinit milnoncombat combat rebel warwin warloss rebelwin rebelloss leveledu age teacher journalism law medicine religion activist careerpolitician creative business aristocratlandowner police militarycareer scienceeng bluecollar gender totalspouses married marriedinpower divorced childtotal parstability illegit royalty orphanbinary officetenure1000 leaderpeaceyrs1 leaderpeaceyrs2 leaderpeaceyrs3 if leadodd==0, robust cluster(leaderid)

predict p
label var p "Predicted Leader Risk Score"

logit cwinit p dem1 dem2 jointdem sideabof defpact contigld syscon satisdy numGPs cwpceyrs1 cwpceyrs2 cwpceyrs3 if leadodd==1, robust cluster(dyadid)

drop p

logit cwinit milnoncombat combat rebel warwin warloss rebelwin rebelloss leveledu age teacher journalism law medicine religion activist careerpolitician creative business aristocratlandowner police militarycareer scienceeng bluecollar gender totalspouses married marriedinpower divorced childtotal parstability illegit royalty orphanbinary officetenure1000 leaderpeaceyrs1 leaderpeaceyrs2 leaderpeaceyrs3 if leadodd==0, robust cluster(leaderid)

predict p
label var p "Predicted Leader Risk Score"

logit cwinit p dem1 dem2 jointdem sideabof defpact contigld syscon satisdy numGPs cwpceyrs1 cwpceyrs2 cwpceyrs3 if leadodd==1, robust cluster(dyadid)

drop p

*/ Randomizing on the country, not the leader year */
logit cwinit milnoncombat combat rebel warwin warloss rebelwin rebelloss leveledu age teacher journalism law medicine religion activist careerpolitician business aristocratlandowner police militarycareer scienceeng bluecollar gender totalspouses married marriedinpower divorced childtotal parstability illegit royalty orphanbinary officetenure1000 leaderpeaceyrs1 leaderpeaceyrs2 leaderpeaceyrs3 if countryrandom==1, robust cluster(leaderid)

predict p
label var p "Predicted Leader Risk Score"

logit cwinit p dem1 dem2 jointdem sideabof defpact contigld syscon satisdy numGPs cwpceyrs1 cwpceyrs2 cwpceyrs3 if countryrandom==0, robust cluster(dyadid)

drop p

logit cwinit milnoncombat combat rebel warwin warloss rebelwin rebelloss leveledu age teacher journalism law medicine religion activist careerpolitician business aristocratlandowner police militarycareer scienceeng bluecollar gender totalspouses married marriedinpower divorced childtotal parstability illegit royalty orphanbinary officetenure1000 leaderpeaceyrs1 leaderpeaceyrs2 leaderpeaceyrs3 if countryrandom==0, robust cluster(leaderid)

predict p
label var p "Predicted Leader Risk Score"

logit cwinit p dem1 dem2 jointdem sideabof defpact contigld syscon satisdy numGPs cwpceyrs1 cwpceyrs2 cwpceyrs3 if countryrandom==1, robust cluster(dyadid)

drop p

*/ footnote 56 on page 120: Stepwise Regression and replication of Table 3.1 */

estimates clear
clear
use WhyLeadersFightDyadicReplication.dta, clear

*/ For illustration purposes, here is one 'run' of a stepwise model to show what it selects: see the accompanying note for more on the methodology */
stepwise, pr(.20): logit cwinit milnoncombat combat rebel warwin warloss rebelwin rebelloss leveledu age teacher journalism law medicine religion activist careerpolitician creative business aristocratlandowner police militarycareer scienceeng bluecollar gender totalspouses married marriedinpower divorced childtotal parstability illegit royalty orphanbinary officetenure1000 leaderpeaceyrs1 leaderpeaceyrs2 leaderpeaceyrs3

logit cwinit milnoncombat combat royalty warwin warloss rebelwin rebelloss age teacher law medicine religion activist careerpolitician parstability business aristocratlandowner militarycareer illegit divorced marriedinpower totalspouses leaderpeaceyrs1 leaderpeaceyrs2 leaderpeaceyrs3 if random==1, robust cluster(leaderid)

predict p
label var p "Predicted Leader Risk Score"

drop if random==1

logit cwinit p dem1 dem2 jointdem sideabof defpact contigld syscon satisdy numGPs cwpceyrs1 cwpceyrs2 cwpceyrs3 if random==0, robust cluster(dyadid)

margins, atmeans vsquish
margins, atmeans at((p10)syscon) at((p90) syscon) at(contigld=0) at(contigld=1) at(dem1=1 dem2=1 jointdem=1) at((p10)satisdy) at((p90)satisdy) at((p10)numGPs) at((p90)numGPs) at(defpact=0) at(defpact=1) at((p10)sideabof) at((p90)sideabof) at((p10)p) at((p90)p) vsquish

*/ REPLICATION OF TABLE 3.1 AND FIGURE 3.14 WITH UPDATED DATASET */

estimates clear
clear
use WhyLeadersFightDyadicReplication_updated.dta, clear

*/ Table 3.1 */
*/ Uses leader peace year splines, not country peace year splines, as per footnote 57 on page 120 */

logit cwinit milnoncombat combat rebel warwin warloss rebelwin rebelloss leveledu age teacher journalism law medicine religion activist careerpolitician creative business aristocratlandowner police militarycareer scienceeng bluecollar gender totalspouses married marriedinpower divorced childtotal parstability illegit royalty orphanbinary officetenure1000 leaderpeaceyrs1 leaderpeaceyrs2 leaderpeaceyrs3 if random==1, robust cluster(leaderid)
estimates store m1

predict p
label var p "Predicted Leader Risk Score"

drop if random==1

logit cwinit p dem1 dem2 jointdem sideabof defpact contigld syscon satisdy numGPs cwpceyrs1 cwpceyrs2 cwpceyrs3 if random==0, robust cluster(dyadid)
estimates store m2

margins, atmeans vsquish
margins, atmeans at((p10)syscon) at((p90) syscon) at(contigld=0) at(contigld=1) at(dem1=1 dem2=1 jointdem=1) at((p10)satisdy) at((p90)satisdy) at((p10)numGPs) at((p90)numGPs) at(defpact=0) at(defpact=1) at((p10)sideabof) at((p90)sideabof) at((p10)p) at((p90)p) vsquish

*/ Use these to generate Table 3.1 */

*/ Figure 3.14 */

margins, atmeans at((min)p) at((p10)p) at((p20)p) at((p30)p) at((p40)p) at((p50)p) at((p60)p) at((p70)p) at((p80)p) at((p90)p)

*/ CLOSE LOG FILE */

log close

*/ CLEAR DATASET */

clear
